package com.luchao.ptz.repository;

import com.alibaba.fastjson.JSONObject;
import com.luchao.ptz.pojo.ZblogPost;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ZblogPostRepository extends JpaRepository<ZblogPost, Long> {

    @Query(value = "SELECT pth.tid,pth.`subject`,pth.postdate,pth.lastpost,pth.hits,pth.fid,ptm.tags,ptm.content FROM pw_threads pth LEFT JOIN pw_tmsgs ptm ON pth.tid=ptm.tid WHERE pth.fid !=0 ORDER BY pth.tid DESC", nativeQuery = true)
    List<JSONObject> getAllInfo();

    @Query(value = "SELECT * FROM nzbp_post", nativeQuery = true)
    List<ZblogPost> getAll();

    @Query(value = "SELECT * FROM nzbp_post where log_CreateTime = ?1", nativeQuery = true)
    ZblogPost getByPostDate(Integer postDate);

}
